var isUnitClick = false;
$(function(){ 
	$('#unit').click(function(){
		if(isUnitClick){
			return;
		}
		isUnitClick =true;
		var value =$(this).val();
		$('#unit').combogrid({
			rownumbers:true,
			pagination:true, 
			panelWidth:450,
			width:186,
			idField:'dictionaryID',
			textField:'dictionaryName',
			url:js+'dict/chooseDictionary.action?type=Unit',
			columns:[[
				{field:'dictionaryCode',title:'单位编号',width:100},
				{field:'dictionaryName',title:'单位名称',width:100}
			]],					
			filter:function(q,row){  
				if(row.unitCode.toUpperCase().indexOf(q.toUpperCase())>=0) return true;
			},
			toolbar:[
			 	{text:'清空',iconCls:'icon-no',	handler:function(){ $('#unit').combogrid('clear');  $('#unitID').val('');  $('#unit').val('');}},
			 	'-',
			 	{text:'确定',iconCls:'icon-ok',handler:function(){$('#unit').combogrid('hidePanel'); }}]
			 ,onHidePanel:function(){
					var unitID = $('#unit').combogrid('getValue');
					var hidden = $('#unitID').val();
					if(hidden==unitID||unitID==''){
						return;
					}
					$('#unitID').val(unitID);
			    }
		});	
		$('#unit').combogrid('setText',value);
	})	   
})
